"ui";
let gz2 = '22';
ui.layout(
    <vertical >
        <vertical margin="30">
        <text textSize="24">功能说明：</text>
        <text>切换到抖音商家的评论页面，点击最新或者综合。然后点击这里的运行，打开悬浮窗，打开抖音，调整到合适的位置，点击悬浮窗的运行。</text>
        </vertical>
         {/* <horizontal margin="30">
            <text>是否测试</text>
            <input id="run_count_input" text="" hint="请输入运行数量" w="auto" />
        </horizontal> */}
        <horizontal margin="30">
            <text id="text_run_count">运行数量</text>
            
            <input id="input_run_count" text="300" hint="请输入运行数量" w="*" layout_gravity="right|top" gravity="right"/>
            
        </horizontal>

        <horizontal margin="30">
            <text id="text_guanzhu">关注概率：70%</text>
            <seekbar id="seekbar_guanzhu" text=""  max="100" progress="70" step="1" w="*"/>
        </horizontal>
        <horizontal margin="30">
            <text id="text_dianzan">点赞概率：70%</text>
            <seekbar id="seekbar_dianzan" text=""  max="100" progress="70" step="1" w="*"/>
        </horizontal>
        <horizontal margin="30">
            <text id="text_shoucang">收藏概率：70%</text>
            <seekbar id="seekbar_shoucang" text=""  max="100" progress="70" step="1" w="*"/>
        </horizontal>
        <horizontal margin="30">
            <text id="text_pinglun">评论概率：70%</text>
            <seekbar id="seekbar_pinglun" text=""  max="100" progress="70" step="1" w="*"/>
        </horizontal>
        
        <button id="btn_ok" text="开始" margin="30"></button>
    </vertical>
);

// let runCount = 300;
// let guanzhu = 70;
// let dianzan = 70;
// let shoucang = 70;
var storage = storages.create("douyin");
let runCount = storage.get('runCount')||300;
let guanzhu = storage.get('guanzhu')||70;
let dianzan = storage.get('dianzan')||70;
let shoucang = storage.get('shoucang')||70;
let pinglun = storage.get('pinglun')||70;

ui.input_run_count.setText(runCount+"");
ui.seekbar_guanzhu.setProgress(parseInt(guanzhu));
ui.text_guanzhu.setText('关注概率：'+guanzhu+'%');
ui.seekbar_dianzan.setProgress(parseInt(dianzan));
ui.text_dianzan.setText('点赞概率：'+dianzan+'%');
ui.seekbar_shoucang.setProgress(parseInt(shoucang));
ui.text_shoucang.setText('收藏概率：'+shoucang+'%');
ui.seekbar_pinglun.setProgress(parseInt(pinglun));
ui.text_pinglun.setText('评论概率：'+pinglun+'%');
ui.seekbar_guanzhu.setOnSeekBarChangeListener(new android.widget.SeekBar.OnSeekBarChangeListener({
    onProgressChanged: function(seekBar, progress, fromUser) {
        ui.text_guanzhu.setText('关注概率：'+progress+'%')
    }
}));
ui.seekbar_dianzan.setOnSeekBarChangeListener(new android.widget.SeekBar.OnSeekBarChangeListener({
    onProgressChanged: function(seekBar, progress, fromUser) {
        ui.text_dianzan.setText('点赞概率：'+progress+'%')
    }
}));
ui.seekbar_shoucang.setOnSeekBarChangeListener(new android.widget.SeekBar.OnSeekBarChangeListener({
    onProgressChanged: function(seekBar, progress, fromUser) {
        ui.text_shoucang.setText('收藏概率：'+progress+'%')
    }
}));
ui.seekbar_pinglun.setOnSeekBarChangeListener(new android.widget.SeekBar.OnSeekBarChangeListener({
    onProgressChanged: function(seekBar, progress, fromUser) {
        ui.text_pinglun.setText('评论概率：'+progress+'%')
    }
}));

ui.btn_ok.click( ()=>  {
	// toast('asdfas')
	// showBLayout.showBLayout()
    // let runCount = ui.input_run_count.getText();
    // console.log("获取到的运行数量为: " + runCount);

    storage.put("runCount", ui.input_run_count.getText()+"");
    storage.put("guanzhu", ui.seekbar_guanzhu.getProgress()+"");
    storage.put("dianzan", ui.seekbar_dianzan.getProgress()+"");
    storage.put("shoucang", ui.seekbar_shoucang.getProgress()+"");
    storage.put("pinglun", ui.seekbar_pinglun.getProgress()+"");
    // console.log('xxx',storage.get("runCount"));
    // engines.execScriptFile("./douyin.js");
    const common = require('./common.js'); 
    common.openStarBtn("./douyin.js");
    app.launchApp("抖音");

})